package com.gjt.zyglxt.dao;

import java.util.Date;

import com.gjt.zyglxt.model.Consume;


import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * ConsumeDao
 */
public interface IConsumeDao extends JpaRepository<Consume,Integer>,JpaSpecificationExecutor<Consume>{

    //查询会员最后一次进入资源室的日志编号
   /*  @Query(value = "select * from consume where in_time = (select max(in_time) from consume where card_no = :cardNo)",nativeQuery = true) */
   @Query(value = "select * from consume where in_time = (select max(in_time) from consume where card_no = :cardNo)  ",nativeQuery = true)
   Consume getMaxInTime(String cardNo);

    //更新离开时间
    @Modifying//更新操作
    @Query(value = "update consume c set c.out_time= :outTime where c.id = :id",nativeQuery = true)
    int updateOutTime(int id,Date outTime);

	
}